<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 

<!-- / container -->
<div id="login">
	<div class="sign up2">
		<div class="al-wrp">
			<div class="clr fa-h3" id="fa-h3">
				<h3>
					<span class="fa-rv">直接选择收藏夹 (点击收藏夹名即可)</span>
				</h3>
			</div>
			<div class="al-u clr" id="my-fav-list">
				<c:forEach items="${userCommidityFavorites}" var="userCommidityFavorite"  varStatus="item" >
					<a class="${userCommidityFavorite.defaultType == 1 ? 'cur' :  ''}" href="javascript:tietiao('${commodityId}','${userCommidityFavorite.favoriteId }');">${userCommidityFavorite.favoriteName }</a>
				</c:forEach>
			</div>
			
			<div id="fa-creatalb" class="fa-albu-new fa-crttog">
				<div class="l fa-cabinp">
						<input type="text" id="new-fav" autocomplete="off" class="ipt l" name="name" value="" maxlength="40">
						<button class="button sign" onclick="javascript:addFav();" type="submit">新建收藏夹</button>
				</div>
			</div>
			
		</div>
	</div>
</div>	
<script type="text/javascript">

var tietiaoComId = '${commodityId}';
// 添加收藏夹
function addFav() {
	var favoriteNa = $('#new-fav').val();
	if(com.tietiao.Validator.isEmptyStr(favoriteNa)) {
		return ;
	}
	$.post('common_common_addFav.htm',{favoriteName:favoriteNa},function(data) {
		var msg = eval('(' + data + ')');
		if(msg.suc == 'true') {
			$('#my-fav-list').append('<a href="javascript:tietiao('+ tietiaoComId +','+ msg.msg +');">'+ $('#new-fav').val() +'</a>');
			 $('#new-fav').val('');
		}
		else {
			com.tietiao.timeAlert(msg.msg,1,true);
		}
	});
}
//贴条
function tietiao(comId,favId) {
	com.tietiao.tietiao(comId,favId,null,function(){
		$.dialog.list['show_tie_'+comId ].close();
		var tieNum = $('#tietiao_num_' + comId).html();
		tieNum = tieNum.substring(1,tieNum.length);
		tieNum = new Number(tieNum) + 1;
		if($('#tietiao_num_' + comId).length > 0 ) {
			$('#tietiao_num_' + comId).html('+' + tieNum);
			$('#tie_shi_' + comId).html('<span></span>撕条');
			$('#tie_shi_' + comId).attr('href','javascript:com.tietiao.shitiao('+ comId +')');
			$('#tie_shi_' + comId).attr('class','followed');
		}
		
		if($('#tietiao_num_detail_' + comId).length > 0 ) {
			$('#tietiao_num_detail_' + comId).html('+' + tieNum);
			$('#tie_shi_detail_' + comId).html('<span></span>撕条');
			$('#tie_shi_detail_' + comId).attr('href','javascript:com.tietiao.shitiao('+ comId +')');
			$('#tie_shi_detail_' + comId).attr('class','followed');
			
			$('#tie_shi_button_' + comId).html('<span></span>撕条');
			$('#tie_shi_button_' + comId).attr('href','javascript:com.tietiao.shitiao('+ comId +')');
			$('#tie_shi_button_' + comId).attr('class','followed');
		}
		
	},function(){
		
	});
}

</script>